<template>
  <div class="detail">
    <h3>{{ detail.title }}</h3>
    <text>{{ detail.content }}</text>
    <div class="imgList" v-for="(item, index) in imgList" :key="index" v-show="detail.picUrl">
      <img :src="item.url" mode="aspectFill">
      <p>{{ item.pic_title }}</p>
    </div>
     <!-- 广告位 -->
    <ad unit-id="adunit-98d66e99291778e5" @error="adError" v-show="showAd"></ad>
  </div>
</template>
<script>
export default {
  data () {
    return {
      detail: {},
      imgList: [],
      showAd: true
    }
  },
  mounted () {
    wx.showLoading({
      title: '加载中'
    })
    this.detail = wx.getStorageSync('historyDetail')
    if (this.detail.picUrl) {
      this.imgList = JSON.parse(this.detail.picUrl)
    }
    wx.hideLoading()
  },
  onLoad () {
    this.detail = {}
    this.imgList = []
  },
  methods: {
    adError () {
      this.showAd = false
    }
  }
}
</script>
<style lang="scss" scoped>
.detail {
  padding: 0 10px;
  h3 {
    text-align: left;
    margin: 10px 0;
    font-weight: bold;
  }
  p {
    text-align: justify;
  }
  .imgList {
    margin: 10px 0;
    img {
      width: 100%;
    }
    p {
      text-align: center;
      font-size: 16px;
      margin: 10px 0;
    }
  }
}
</style>
